package com.example.rabbitmq.consumer;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

@Component
public class MessageConsumer {

    @RabbitListener(queues = "queue1")
    public void receiveMessageFromQueue1(String message) {
        System.out.println("Received from queue1: " + message);
    }

    @RabbitListener(queues = "queue2")
    public void receiveMessageFromQueue2(String message) {
        System.out.println("Received from queue2: " + message);
    }

//    @Value("${spring.rabbitmq.listener.queue}")
//    private String queueName;
//
//    @RabbitListener(queues = "#{queueName}")
//    public void receiveMessage(String message) {
//        System.out.println("Received from " + queueName + ": " + message);
//    }
//
//    @Configuration
//    public static class RabbitConfig {
//
//        @Value("${spring.rabbitmq.listener.queue}")
//        private String queueName;
//
//        @Bean
//        public String queueName() {
//            return queueName;
//        }
//    }
}
